import state from "./state";

export const currentUser = state => {
  if(!state.currentUser){
    return state.currentUser
  }
  if(!state.currentUser.photo){
    state.currentUser.photo = 'https://gok-file.obs.cn-south-1.myhwclouds.com/default.png';
    return state.currentUser
  }else{
    let pattA = new RegExp("http");
    let pattB = new RegExp("static");
    let resultA = pattA.test(state.currentUser.photo);
    let resultB = pattB.test(state.currentUser.photo);
    if(!resultA && !resultB){
      state.currentUser.photo = 'static' + state.currentUser.photo
    }
  } 
  return state.currentUser
}
export const isLogin = state => state.isLogin
export const cityId = state => state.cityId
export const cityName = state => state.cityName
export const resetFlag = state => state.resetFlag
export const needSupplyInfo = state => state.needSupplyInfo
export const needPayBool = state => state.needPayBool
export const dialogClose = state => state.dialogClose
export const tradeRecord = state => state.tradeRecord
export const firstPayBool = state => state.firstPayBool
export const cityList = state => state.cityList
export const cityListAll = state => state.cityListAll
export const showEmailBtnBool = state => state.showEmailBtnBool
export const QQNum = state => {
  return Number(state.QQNum)
}
export const servicePhone = state => {
  let hh, mm, ss;
  hh = state.servicePhone.slice(0, 3)
  mm = state.servicePhone.slice(3, 7)
  ss = state.servicePhone.slice(7);
  return `客服电话：${hh}-${mm}-${ss}`
}
export const resultCourse = state => state.resultCourse
export const freeTime = state => state.freeTime
export const unreadNumber = state => state.unreadNumber
export const unreadlsNumber = state => state.unreadlsNumber
